$(document).ready(function() {
    decorateToggleDetailsVisibility();
});

function togglePendingMethodsTable(toggle) {
    var pendingMethods = $('#pending-methods');
    
    if ($(toggle).attr('checked')) {
        pendingMethods.show();
    }
    else {
        pendingMethods.hide();
    }
}

/**
 * Decorates the TestNG-XSLT javascript function toggleDetailsVisibility() to
 * add some behaviors.
 */
function decorateToggleDetailsVisibility() {
    var original = toggleDetailsVisibility;
    
    window.toggleDetailsVisibility = function(elementId) {
        if (/_details$/.test(elementId)) {
            var exceptionId = elementId.replace(/details$/, 'exception');
            
            // hide all others
            $('.testMethodDetailsVisible').each(function() {
                if (this.id != elementId && this.id != exceptionId) {
                    this.className = 'testMethodDetails';
                }
            });
            
            var resultId = $(document.getElementById(elementId))
                .attr('result-id');
            
            // set frame
            top.frames['details'].location = 'test-result-' + resultId + '.xml';
        }
        
        original(elementId);
    }
}

